home *** CD-ROM | disk | FTP | other *** search
/ How Many Bugs in a Box / How Many Bugs in a Box.cdr / bugs / act7 / 00026.ls < prev    next >
Encoding:
Text File  |  1995-03-28  |  8.2 KB  |  333 lines

  1. on startMovie
  2.   global exitFrame, lastchan, genericbug, bugcast, tablecast, rewardlist, closedbox, openbox, blevel, game7level, sblist, newbugs, semisin
  3.   set openbox to the number of cast "open"
  4.   set closedbox to the number of cast "closed"
  5.   set rewardlist to 0
  6.   set the preLoadEventAbort to 1
  7.   set tablecast to []
  8.   repeat with xxx = 1 to 13
  9.     add(tablecast, the number of cast ("table" & xxx))
  10.   end repeat
  11.   set bugcast to []
  12.   repeat with xxx = 1 to 13
  13.     add(bugcast, the number of cast ("p" & xxx & "1"))
  14.   end repeat
  15.   set blevel to game7level + 2
  16.   set genericbug to [-50, -50, 1, 481, 36, 255, 0, 100]
  17.   repeat with xxx = 1 to 48
  18.     set the visible of sprite xxx to 1
  19.   end repeat
  20.   set semisin to [:]
  21.   addProp(semisin, 0, -3)
  22.   addProp(semisin, -3, -3)
  23.   addProp(semisin, -3, 0)
  24.   addProp(semisin, -3, 3)
  25.   addProp(semisin, 0, 3)
  26.   addProp(semisin, 3, 3)
  27.   addProp(semisin, 3, 0)
  28.   addProp(semisin, 3, -3)
  29.   set sblist to [:]
  30. end
  31.  
  32. on generatebugs
  33.   global buglist, game7level, bgroup, bnumber
  34.   set buglist to [:]
  35.   if game7level < 1 then
  36.     set game7level to 1
  37.   end if
  38.   if game7level = 1 then
  39.     set bgroup to 3
  40.     set bnumber to 4
  41.   else
  42.     if game7level = 2 then
  43.       set bgroup to 4
  44.       set bnumber to 5
  45.     else
  46.       set bgroup to 3
  47.       set bnumber to 10
  48.       set the visible of sprite 2 to 0
  49.     end if
  50.   end if
  51.   set quicklist to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
  52.   repeat with xxx = 1 to 5
  53.     if xxx <= bgroup then
  54.       set btype to random(count(quicklist))
  55.       set bbug to getAt(quicklist, btype)
  56.       deleteAt(quicklist, btype)
  57.       set dingy to random(bnumber)
  58.       addProp(buglist, bbug, dingy)
  59.       if game7level < 3 then
  60.         puppetSprite(16 + xxx, 1)
  61.         puppetSprite(11 + xxx, 1)
  62.         set the castNum of sprite (16 + xxx) to the number of cast ("digit" & dingy)
  63.         set the castNum of sprite (11 + xxx) to the number of cast ("bug" & bbug)
  64.         set the visible of sprite (16 + xxx) to 1
  65.         set the visible of sprite (11 + xxx) to 1
  66.       end if
  67.       next repeat
  68.     end if
  69.     set the visible of sprite (16 + xxx) to 0
  70.     set the visible of sprite (11 + xxx) to 0
  71.   end repeat
  72. end
  73.  
  74. on saylist
  75.   global game7level, add, loclock, animtimer, idealnum, reachcur, grabcur, buglist
  76.   puppetSound(0)
  77.   repeat while the mouseDown
  78.     updateStage()
  79.   end repeat
  80.   talkyou("saylist intro")
  81.   cursor(4)
  82.   set loclock to the frame
  83.   set invertlist to []
  84.   repeat with ddd = 1 to count(buglist)
  85.     add(invertlist, the castNum of sprite (11 + ddd))
  86.   end repeat
  87.   repeat with ddd = 1 to count(buglist)
  88.     set the castNum of sprite (11 + ddd) to the castNum of sprite (11 + ddd) + 1
  89.     updateStage()
  90.     if the mouseDown then
  91.       exit repeat
  92.     end if
  93.     talkyou("s" & getAt(buglist, ddd))
  94.     if the mouseDown then
  95.       exit repeat
  96.     end if
  97.     if getAt(buglist, ddd) > 1 then
  98.       talkyou("*s" & getPropAt(buglist, ddd))
  99.     else
  100.       talkyou("*" & getPropAt(buglist, ddd))
  101.     end if
  102.     if the mouseDown then
  103.       exit repeat
  104.     end if
  105.   end repeat
  106.   repeat with ddd = 1 to count(buglist)
  107.     set the castNum of sprite (11 + ddd) to getAt(invertlist, ddd)
  108.   end repeat
  109.   set reachcur to the number of cast "cursorpos"
  110.   set grabcur to the number of cast "cursorpos2"
  111.   set animtimer to 0
  112.   unLoadCast(the number of cast "s8", the number of cast "click")
  113.   unLoadCast(the number of cast "Catch a Bug", the number of cast "neg04")
  114.   cursor(4)
  115.   preLoadCast("p11", "lastbug")
  116.   repeat with xxx = 1 to count(buglist)
  117.     set pickle to "table" & getPropAt(buglist, xxx)
  118.     preLoadCast("table" & getPropAt(buglist, xxx), "table" & getPropAt(buglist, xxx) + 1)
  119.   end repeat
  120.   cursor([reachcur, reachcur + 1])
  121.   go("gameloop")
  122. end
  123.  
  124. on sayandwait soundname
  125.   puppetSound(soundname)
  126.   repeat while not (the soundBusy)
  127.     updateStage()
  128.   end repeat
  129.   repeat while the soundBusy
  130.     updateStage()
  131.   end repeat
  132. end
  133.  
  134. on stopMovie
  135.   repeat with xxx = 1 to 48
  136.     set the visible of sprite xxx to 1
  137.   end repeat
  138. end
  139.  
  140. on addbug overridetype
  141.   global sblist, genericbug, caughtbugs, idealnum
  142.   if overridetype < 1 then
  143.     set overridetype to 0
  144.   end if
  145.   set thischan to 0
  146.   if count(sblist) < idealnum then
  147.     set thischan to freechan()
  148.     sactivate(thischan, genericbug)
  149.     set bugtype to decidebug(thischan, overridetype)
  150.     set spawn to birth(script "bughive", thischan, bugtype)
  151.     addProp(sblist, thischan, spawn)
  152.   end if
  153.   return thischan
  154. end
  155.  
  156. on directtest
  157.   repeat with yyy = -10 to 10
  158.     set rump to EMPTY
  159.     repeat with xxx = -10 to 10
  160.       set rump to rump && directix(0, 0, xxx, yyy)
  161.     end repeat
  162.     put rump
  163.   end repeat
  164. end
  165.  
  166. on directix sx, sy, dx, dy
  167.   set dirx to (dx - sx) / 2
  168.   set diry to (dy - sy) / 2
  169.   if dirx < 0 then
  170.     if diry < 0 then
  171.       set direct to 1
  172.     else
  173.       if diry > 0 then
  174.         set direct to 3
  175.       else
  176.         set direct to 2
  177.       end if
  178.     end if
  179.   else
  180.     if dirx > 0 then
  181.       if diry < 0 then
  182.         set direct to 7
  183.       else
  184.         if diry > 0 then
  185.           set direct to 5
  186.         else
  187.           set direct to 6
  188.         end if
  189.       end if
  190.     else
  191.       if diry < 0 then
  192.         set direct to 0
  193.       else
  194.         set direct to 4
  195.       end if
  196.     end if
  197.   end if
  198.   return direct
  199. end
  200.  
  201. on showinfo
  202.   global sblist, prisoners, buglist
  203.   repeat with xxx = 1 to count(sblist)
  204.     buginfo(getAt(sblist, xxx))
  205.   end repeat
  206. end
  207.  
  208. on decidebug thischan, overridetype
  209.   global game7level, buglist, bugcast, WhichBug, prisoners
  210.   set bugtype to random(13)
  211.   if random(2) = 1 then
  212.     set grababug to 1
  213.     set thingy to buglist - prisoners
  214.     repeat while getAt(thingy, grababug) < 1
  215.       set grababug to grababug + 1
  216.       if grababug > count(prisoners) then
  217.         set grababug to random(count(prisoners))
  218.         exit repeat
  219.       end if
  220.     end repeat
  221.     set bugtype to getPropAt(buglist, grababug)
  222.   end if
  223.   if overridetype > 0 then
  224.     set bugtype to overridetype
  225.   end if
  226.   if bugtype < 7 then
  227.     set shaftx to 710
  228.     set shafty to ((random(2) - 1) * 600) - 60
  229.     if random(2) = 1 then
  230.       set shaftx to random(440) + 200
  231.     else
  232.       set shafty to random(600) - 60
  233.     end if
  234.   else
  235.     if bugtype < 11 then
  236.       set shafty to ((random(2) - 1) * 245) + 231
  237.       set shaftx to 710
  238.     else
  239.       set shaftx to 640
  240.       set shafty to (random(2) - 1) * 480
  241.       if random(2) = 1 then
  242.         set shaftx to random(440) + 200
  243.       else
  244.         set shafty to random(480)
  245.       end if
  246.     end if
  247.   end if
  248.   set the castNum of sprite thischan to getAt(bugcast, bugtype)
  249.   set the locH of sprite thischan to shaftx
  250.   set the locV of sprite thischan to shafty
  251.   return bugtype
  252. end
  253.  
  254. on freechan
  255.   global sblist
  256.   set trying to 23
  257.   repeat while objectp(getaProp(sblist, trying))
  258.     set trying to trying + 1
  259.   end repeat
  260.   return trying
  261. end
  262.  
  263. on sgn param
  264.   if param > 0 then
  265.     return 1
  266.   else
  267.     if param < 0 then
  268.       return -1
  269.     else
  270.       return 0
  271.     end if
  272.   end if
  273. end
  274.  
  275. on killbug param
  276.   global sblist
  277.   if objectp(getaProp(sblist, param)) then
  278.     deleteProp(sblist, param)
  279.   end if
  280. end
  281.  
  282. on allofus
  283.   global sblist
  284.   repeat with X = 1 to count(sblist)
  285.     buginfo(getaProp(sblist, getAt(sblist, X)))
  286.   end repeat
  287. end
  288.  
  289. on sdeact params
  290.   set params to string(params)
  291.   set num to the number of words in params
  292.   repeat with xxx = 1 to num
  293.     set snum to value(word xxx of params)
  294.     set the locV of sprite snum to the locV of sprite snum
  295.     puppetSprite(snum, 0)
  296.   end repeat
  297.   updateStage()
  298. end
  299.  
  300. on sactivate sold, params
  301.   puppetSprite(sold, 1)
  302.   if listp(params) <> EMPTY then
  303.     set the locH of sprite sold to getAt(params, 1)
  304.     set the locV of sprite sold to getAt(params, 2)
  305.     set the type of sprite sold to getAt(params, 3)
  306.     set the castNum of sprite sold to getAt(params, 4)
  307.     set the ink of sprite sold to getAt(params, 5)
  308.     set the foreColor of sprite sold to getAt(params, 6)
  309.     set the backColor of sprite sold to getAt(params, 7)
  310.     set the blend of sprite sold to getAt(params, 8)
  311.   end if
  312. end
  313.  
  314. on sinfo sold
  315.   set stemp to []
  316.   add(stemp, the locH of sprite sold)
  317.   add(stemp, the locV of sprite sold)
  318.   add(stemp, the type of sprite sold)
  319.   add(stemp, the castNum of sprite sold)
  320.   add(stemp, the ink of sprite sold)
  321.   add(stemp, the foreColor of sprite sold)
  322.   add(stemp, the backColor of sprite sold)
  323.   add(stemp, the blend of sprite sold)
  324.   return stemp
  325. end
  326.  
  327. on shit
  328.   global sblist
  329.   repeat with xxx in sblist
  330.     put xxx
  331.   end repeat
  332. end
  333.